import java.io.IOException;
import java.io.InputStreamReader;
import java.io.LineNumberReader;

public class Main
{
  public static void main(String[] args) throws IOException
  {
    Lexico lexico = new Lexico();
    Sintatico sintatico = new Sintatico();
    Semantico semantico = new Semantico();

    LineNumberReader in = new LineNumberReader(new InputStreamReader(System.in));
    String line = in.readLine();

    lexico.setInput( line );

    try
    {
      sintatico.parse(lexico, semantico);
      System.out.println(" = ");
      System.out.println(semantico.getResult());
    }
    catch ( LexicalError e )
    {
      e.printStackTrace();
    }
    catch ( SyntaticError e )
    {
      e.printStackTrace();
    }
    catch ( SemanticError e )
    {
      e.printStackTrace();
    }
  }
}